#include <iostream>
#define N 100

using namespace std;

void mirror(int array[], int elements){
int i,j, aux;
i=0;
j=elements-1;
while (i<j){
	aux=array[i];
	array[i]=array[j];
	array[j]=aux;
	++i;
	--j;
}
}


int transform(int array[], int number, int base){	
int i=0;
do{
	array[i]=number%base;
	number /= base;
	++i;}
while (number>0);
	mirror(array, i);
return i;			
}


void printintVector(int array[], int elements){
for (int i=0; i<elements; i++){
	cout<<array[i]<<" ";}
	cout<<"\n";
}

int main(){
int array[N];
int elements;
int number;
int base;
cout<<"Type a number in base 10: ";
cin>>number;
cout<<"Type a base between 2 and 9: ";
cin>>base;
elements=transform(array, number, base);
cout<<"The number "<< number <<" in base "<< base << " is ";
printintVector(array, elements);
return 0;
}

